package com.xzy.ec.controller;


import com.xzy.ec.entity.GoodSpecsVO;
import com.xzy.ec.entity.PmsGoodsSpecs;
import com.xzy.ec.result.R;
import com.xzy.ec.service.IPmsGoodsSpecsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xzy
 * @since 2022-06-05
 */
@RestController
@RequestMapping("/pmsGoodsSpecs")
@Api(value = "PmsGoodsSpecsController",tags = "规格控制器")
public class PmsGoodsSpecsController{
    @Resource(name = "goodSpecsVOImpl")
    IPmsGoodsSpecsService service;
    //获取所有商品
    @PostMapping("/getAllGoodSpecsVO")
    @ApiOperation(value = "getAllGoodSpecsVO",notes = "获取所有商品VO")
    public R getAllGoodSpecsVO(){
        List<GoodSpecsVO> res= service.getAllGoodSpecsVO();
        System.out.println(res);
        return R.ok().data("goodSpecsVOList", res);
    }

    //添加商品
    @PostMapping("/addGoodsSpecs")
    @ApiOperation(value = "addGoodsSpecs",notes = "添加商品信息")
    public R addGoodsSpecs(@ApiParam(name = "pmsGoodsSpecs",value = "商品信息",required = true) PmsGoodsSpecs pmsGoodsSpecs){
        if (service.save(pmsGoodsSpecs))return R.ok();
        return R.error();
    }
    //修改商品
    @PostMapping("/updateGoodsSpecs")
    @ApiOperation(value = "updateGoodsSpecs",notes = "添加商品信息")
    public R updateGoodsSpecs(@ApiParam(name = "pmsGoodsSpecs",value = "商品信息",required = true) PmsGoodsSpecs pmsGoodsSpecs){
        if (service.updateById(pmsGoodsSpecs))return R.ok();
        return R.error();
    }

}

